<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>CCRM管理平台</title>
    <link href="${gPath}/styles/dpl-min.css" rel="stylesheet"/>
    <link href="${gPath}/styles/bui-min.css" rel="stylesheet"/>
    <link href="${gPath}/styles/main.css" rel="stylesheet"/>
</head>
<body>
<div class="container">
<div class="row">
    <div class="span24">
        <h1 class="pull-left span18">导入订单</h1>
        <div class="span18">
            <h3>说明：</h3>
            <p>1.可用网店管家导出订单为EXCEL表，导出的订单文件需具备以下字段：<br>
                订单编号<br>
                原始单号<br>
                网名<br>
                货品编号<br>
                数量<br>
                店铺<br>
                物流单号<br>
                电话<br>
                地址</p>
            <p>2.或者下载EXCEL表格模板，填充数据，再导入。 </p>
            <a target="_blank" href="http://cy-clmp.qiniudn.com/clmp%E8%AE%A2%E5%8D%95%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BFV1.1.xlsx" class="button">下载EXCEL表格模板</a>
        </div>
    </div>
    <div class="span24">
        <hr>
        <div id="J_Uploader" style="margin-left: 8px;"></div>
    </div>
    <!--<a class="close-reveal-modal">&#215;</a>-->
</div>

<div class="row">
    <div class="text-center importing" style="display: none;">
        <div class="tips tips-small tips-info span5 offset7">
            <span class="x-icon x-icon-small x-icon-info"><i class="icon icon-white icon-info"></i></span>
            <div class="tips-content">正在导入中，请稍后...</div>
        </div>
    </div>
</div>

<div class="row">
    <h3 id="importMsg"></h3>
    <h2>导入成功的数据：</h2>
    <div class="span24">
        <div id="grid">

        </div>
    </div>
</div>
</div>

<script type="text/javascript" src="${gPath}/scripts/jquery/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="${gPath}/scripts/bui.js"></script>
<script type="text/javascript" src="${gPath}/scripts/common/search.js"></script>
<script type="text/javascript">
    BUI.use('bui/uploader',function (Uploader) {
        var uploader = new Uploader.Uploader({
            render: '#J_Uploader',
            url: '${gPath}/res/_webApi/excel/order',
            queue: {
                resultTpl:{
                    'error': '<div class="error"><span class="uploader-error">{msg}</span></div>'
                }
            },
            rules: {
                //文的类型
                ext: ['.xls,.xlsx,.xlsm','文件类型只能为{0}'],
                //上传的最大个数
                max: [5, '文件的最大个数不能超过{0}个'],
                //文件大小的最小值,这个单位是kb
                minSize: [1, '文件的大小不能小于{0}KB'],
                //文件大小的最大值,单位也是kb
                maxSize: [1024, '文件大小不能大于1M']
            },
            isSuccess: function(result){
                $("#importMsg").html("");
                $(".importing").hide();
                if(result && result.code == 20001){
                    showSuccessData(result.successData);
                    $("#importMsg").html("结果：成功导入"+result.count+"条数据;<br>"+result.msg);
                    return true;
                }
                BUI.Message.Alert("系统繁忙");
                return false;
            }
        }).render();
        uploader.on("start",function(e){
            $(".importing").show();
        })
    });
    function showSuccessData(dataList){
        $("#grid").html("");
        BUI.use(['bui/grid','bui/data'],function(Grid,Data){
            var Grid = Grid,
                    Format=Grid.Format,
                    columns = [{
                        title : 'A',
                        dataIndex :'A'
                    },{
                        title : 'B',
                        dataIndex :'B'
                    },{
                        title : 'C',
                        dataIndex : 'C'
                    },{
                        title : 'D',
                        dataIndex : 'D'
                    },{
                        title : 'E',
                        dataIndex : 'E'
                    },{
                        title : 'F',
                        dataIndex : 'F'
                    },{
                        title : 'G',
                        dataIndex : 'G'
                    },{
                        title : 'H',
                        dataIndex : 'H'
                    },{
                        title : 'I',
                        dataIndex : 'I'
                    }],
                    data = dataList;

            var grid = new Grid.SimpleGrid({
                render:'#grid',
                columns : columns,
                items : data,
                idField : 'A'
            });

            grid.render();
        });
    }
</script>
</body>
</html>